import { http } from "@/utils/http";
import { idpUrlApi } from "../utils";

export type addTaskDto = {
  name: string;
  taskType: number;
  startTime: string;
  endTime: string;
  taskRank: number;
  mapIds: string[];
  details: string;
};

export type IdpTaskDetailsForFile = {
  filePath: string;
  md5: string;
  checkMd5: boolean;
};

export type IdpTaskDetailsForProcess = {
  processName: string;
  exePath: string;
  checkExePath: boolean;
};
// 添加任务
export const addTask = (data: addTaskDto) => {
  return http.request("post", idpUrlApi("task/add"), { data });
};

export type Result = {
  list: Array<any>;
  total?: number;
};

export type searchTaskDto = {
  name: string;
  pageNum: number;
  pageSize: number;
};

// 任务分页
export const getPage = (params: searchTaskDto) => {
  return http.request<Result>("get", idpUrlApi("task/page"), { params });
};

// 停止任务
export const stopTask = (id: string) => {
  return http.request("put", idpUrlApi("task/" + id));
};

// 获取统计结果
export const getCountResult = (id: string) => {
  return http.request("get", idpUrlApi("task/countResult/" + id));
};
